package com.qf.springbootopenapi.exhandler;

import com.qf.springbootopenapi.vo.ResultVo;
import com.qf.springbootopenapi.vo.ReturnMapVo;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.Map;

/**
 * @author 袁英洛
 * @version 1.0
 * @project open-api-based-on-springboot
 * @description
 * @date 2022/10/19 14:19:09
 */

@RestControllerAdvice //全局异常处理器类，返回的是json数据
public class GlobalExHandler {
    
    
    @ExceptionHandler(Exception.class) //需要处理的异常类型是什么
    public ResultVo handlerEx(Exception e){
        return ResultVo.fail(e.getMessage());
    }
    
    
    @ExceptionHandler(ParamNullException.class)
    public ReturnMapVo handlerParamNullEx(ParamNullException e){
    
        return ReturnMapVo.fail(e.getMsg());
        
    }
}
